import Vue from 'vue'
import App from './App'
import store from './store'

import uView from '@/uni_modules/uview-ui'


Vue.config.productionTip = false

Vue.prototype.$store = store

Vue.use(uView)

import {
	queryUserInfo,
	getDouyinOpenId
} from './common/http/api';
uni.login({
	success: (res) => {
		const {
			code
		} = res
					console.log(code);
		getDouyinOpenId(code).then(res => {
			const {
				code,
				data
			} = res

			if (code === "SUCCESS") {
				Vue.prototype.$openID = data.openid;
				uni.setStorageSync('openId', data.openid)
				Vue.prototype.$session_key = data.session_key;
				queryUserInfo(data.openid).then(userRes => {
					const phoneNo = userRes.data ? userRes.data.phoneNo : ''
					uni.setStorageSync('userPhone', phoneNo)
					Vue.prototype.$store.commit("setPhone", phoneNo)
					Vue.prototype.$store.commit("setUserInfo", userRes.data)
				})
			}

		})
	}
})





App.mpType = 'app'

const app = new Vue({
	...App
})
app.$mount()